home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 May / PersonalComputerWorld-May2008-CoverdiscCD.iso / Software / Full / Nero 7 / Installation / Cab / 83AF5E4E.cab / SpinnerD4AA0EFA.js < prev    next >
Encoding:
Text File  |  2006-06-20  |  4.9 KB  |  122 lines

  1.  
  2. var counter = 0
  3. var spinnerText
  4.     
  5. function initializeSpinner(oParentContainer)
  6.     {
  7.         // Box for display of select value
  8.         var oSpinnerBox;
  9.         // selected <option> element
  10.         var oSpinnerSelect;
  11.         for (n=0; n<oParentContainer.all.length; n++)
  12.         {
  13.             var obj = oParentContainer.all[n];
  14.             if (obj.MCSpinnerSelect == "true") oSpinnerSelect = obj;
  15.             if (obj.MCSpinnerBox == "true") oSpinnerBox = obj;
  16.         }
  17.         var oSpinnerOptSelected = oSpinnerSelect.options[oSpinnerSelect.selectedIndex];
  18.         if (oSpinnerOptSelected == null) oSpinnerOptSelected = oSpinnerSelect.options[0];
  19.         // show selected option in Spinner box
  20.         oSpinnerBox.innerText = oSpinnerOptSelected.innerText
  21.     }
  22.     
  23. function setSpinner()
  24.     {        
  25.         // button user clicked
  26.         var oClickedBtn = event.srcElement;
  27.         // direction (up/down) to move selections, based on button clicked        
  28.         var direction
  29.         if (oClickedBtn.MCSpinnerPlus=="true")direction = "down";
  30.         else direction = "up";
  31.         // identifyl all the elements of the spinner; these include
  32.         // parent container, plus btn, minus btn, box for display of value, and hidden <select> element.
  33.         // Parent container
  34.         //var oParentContainer = .parentElement // change this
  35.         oParentContainer = getSpinnerParent(oClickedBtn)
  36.  
  37.         // Box for display of select value
  38.         var oSpinnerBox;
  39.         // selected <option> element
  40.         var oSpinnerSelect;
  41.         // Plus btn
  42.         var oSpinnerPlus;
  43.         //Minus btn
  44.         var    oSpinnerMinus;
  45.         // selected <option> in <select>
  46.         var oSpinnerOptSelected;
  47.         // spinner box is parent of <select>
  48.         //spinnerBox = oClickedBtn.parentElement;
  49.         // find values for all of above, based on their CSS class names
  50.         for (i=0; i<oParentContainer.all.length; i++)
  51.         {
  52.             var obj = oParentContainer.all[i];
  53.             // MCSpinnerPlus and MCSpinnerMinus are custom properties set in the HTML tags
  54.             // to mark the items as spinner buttons
  55.             if (obj.MCSpinnerPlus == "true") oSpinnerPlus = obj;
  56.             if (obj.MCSpinnerMinus == "true") oSpinnerMinus = obj;
  57.             if (obj.MCSpinnerSelect == "true") oSpinnerSelect = obj;
  58.             if (obj.MCSpinnerBox == "true") oSpinnerBox = obj;
  59.         }    
  60.             
  61.  
  62.         // find selected option
  63.         oSpinnerOptSelected = oSpinnerSelect.options[oSpinnerSelect.selectedIndex];
  64.         // variable for next option to display
  65.         var oNextOpt;
  66.         // set value for next option to display, based on direction (up/down) button clicked
  67.         if (direction == "down") oNextOpt = oSpinnerOptSelected.nextSibling;
  68.         else oNextOpt = oSpinnerOptSelected.previousSibling;
  69.         // if you are on first or last option, oNextOpt might not be valid. If not, stay on current option
  70.         if (oNextOpt == null || oNextOpt.tagName == null) 
  71.         {
  72.             oNextOpt = oSpinnerOptSelected
  73.         }
  74.         // set oNextOpt as selected element
  75.         oNextOpt.selected = true
  76.         // (remember, the real select box is invisible) Show selection contents in spinner box
  77.         oSpinnerBox.innerText = oNextOpt.innerText
  78.         // if there is no next sibling for new selected option, you are at the end, so disable plus btn
  79.         if (oNextOpt.nextSibling == null || oNextOpt.nextSibling.tagName == null) 
  80.         { 
  81.             disableBtn(oSpinnerPlus);
  82.             oCurFocus = oSpinnerMinus;
  83.             oSpinnerMinus.focus();
  84.         }
  85.         // else make sure plus btn is enabled
  86.         else enableBtn(oSpinnerPlus)
  87.         // if there is no previous sibling for new selected option, you are at the beginning, so disable minus btn
  88.         if (oNextOpt.previousSibling == null || oNextOpt.previousSibling.tagName == null)
  89.         {
  90.              disableBtn(oSpinnerMinus);
  91.              oCurFocus = oSpinnerPlus;
  92.              oSpinnerPlus.focus();
  93.         }
  94.         // else make sure minus btn is enabled
  95.         else enableBtn(oSpinnerMinus)        
  96.     }
  97.     function getSpinnerParent(btn)
  98.     {
  99.         var oTempObj = btn
  100.         for (i=0; i<5000; i++)
  101.         {
  102.              oTempObj = oTempObj.parentElement
  103.             if (oTempObj.MCSpinnerContainer == "true") 
  104.             {
  105.                 return oTempObj;
  106.                 break;
  107.             }
  108.             if (oTempObj.tagName == "BODY") return null
  109.         }
  110.     }
  111.     function disableBtn(obj)
  112.     {
  113.         obj.MCTempUnFocusable = "true"
  114.         obj.style.filter = "alpha (opacity = 30)"
  115.     }
  116.     function enableBtn(obj)
  117.     {
  118.         // remove temporary unfocusability
  119.         if (obj.MCTempUnFocusable == "true")obj.MCTempUnFocusable = "false"
  120.         // remove transparency filter
  121.         obj.style.filter = "none"
  122.     }